package com.zbkj.dal.base.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum ShareSettleStatusEnums {
    WAIT_SETTLE("WAIT_SETTLE", "待结算", "预计在订单【已完成】后，获得%s个雅识"),
    SETTLE_FROZEN("SETTLE_FROZEN", "冻结中", "预计在订单【已完成】后，获得%s个雅识"),
    SETTLING("SETTLING", "结算中", "预计在订单【已完成】后，获得%s个雅识"),
    SETTLED("SETTLED", "已结算", "已于%s获得%s个雅识"),
    CLOSED("CLOSED", "已关闭", "订单【已关闭】，获得%s个雅识"),
    // 本期没有退款，不存在退回
    RECALL("RECALL", "已回收", "订单退货退款，收回已结算的%s个雅识"),
    ;

    private final String code;

    private final String desc;

    private final String remarkTemplate;

    public static String getDescByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        return Arrays.stream(ShareSettleStatusEnums.values()).filter(e -> StringUtils.equals(code, e.getCode())).map(ShareSettleStatusEnums::getDesc).findFirst().orElse(null);
    }

    public static String getRemarkByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        return Arrays.stream(ShareSettleStatusEnums.values()).filter(e -> StringUtils.equals(code, e.getCode())).map(ShareSettleStatusEnums::getRemarkTemplate).findFirst().orElse(null);
    }
}
